package com.fantu.demo.controller;



import com.fantu.demo.domian.*;
import com.fantu.demo.service.IDemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("数据API文档")
@RestController
@RequestMapping(value = "/demo")
public class DemoController {

    @Autowired
    IDemoService demoService;

    @GetMapping("/getBar")
    @ApiOperation(value = "每月袋装&散装水泥销售量数据")
    public List<BarEntity> getBar(){
        return demoService.getBar();
    }

    @GetMapping("/getPie")
    @ApiOperation(value = "货物类型销售数据")
    public List<PieEntity> getPie(){
        return demoService.getPie();
    }

    @GetMapping("/getBrokenLine")
    @ApiOperation(value = "2019年每月销售情况数据")
    public List<BrokenLineEntity> getBrokenLine(){
        return demoService.getBrokenLine();
    }

    @GetMapping("/getNorthernData")
    public List<NorthernDataEntity>getNorthernData(){
        return demoService.getNorthernData();
    }

    @GetMapping("/getSouthData")
    public List<SouthEntity> getSouthData(){
        return demoService.getSouthData();
    }

    @GetMapping("/getMCGDtat")
    public List<MCGEntity> getMCGDtat(){
        return demoService.getMCGData();
    }

    @GetMapping("/getCementPlantData")
    public List<CementPlantEntity> getCementPlantData(){
        return demoService.getCementPlantData();
    }

    @GetMapping("/getMap")
    @ApiOperation(value = "地图数据")
    public Object getMap(){
        Map<String,Object> map = new HashMap<>();

        List<MapEntity> list = demoService.getMap();
        List<NorthernDataEntity> northernData = demoService.getNorthernData();
        List<MCGEntity> MCGData = demoService.getMCGData();
        List<SouthEntity> southData = demoService.getSouthData();
        List<CementPlantEntity> cementPlantData = demoService.getCementPlantData();

        map.put("result",list);
        map.put("northernData",northernData);
        map.put("MCGData",MCGData);
        map.put("southData",southData);
        map.put("cementPlantData",cementPlantData);

        return map;
    }

    @GetMapping("/getTable1")
    @ApiOperation(value = "工厂销售单量&销售吨位")
    public List<Table1Entity> getTable1(){
        return demoService.getTable1();
    }

    @GetMapping("/getTable2")
    @ApiOperation(value = "区域销售单量&销售吨位")
    public List<Table2Entity> getTable2(){
        return demoService.getTable2();
    }

    /*@RequestMapping("/bar")
    public String myDemo(){
        return "demo";
    }*/

    /*@RequestMapping("/Echarts")
    public String myEcharts(){
        return "Echarts";
    }*/


   /* @RequestMapping("/migrationMap")
    public String mymigrationMap(){
        return "MigrationMap";
    }*/

    /*@RequestMapping("/getTest")
    public String getTest(){
        return "test";
    }*/
    /*@RequestMapping("/getTest1")
    public String getTest1(){
        return "test1";
    }*/

//    折线图
    /*@GetMapping("/getLine")
    @ResponseBody
    public List<LineEntity> getLine(){
        return demoService.getLine();
    }*/



//    表格的动态显示
    /*@RequestMapping("/fatList")
    public String userList(Model model){
        List<TableEntity> userList=demoService.findAll2();
        model.addAttribute("userList",userList);
        return "list";
    }*/


    /*@GetMapping("/project")
    @ResponseBody
    public List<DemoEntity> myProject(){
        ArrayList<DemoEntity> productArrayList = new ArrayList<>();
        DemoEntity de1 = new DemoEntity();
        DemoEntity de2 = new DemoEntity();
        DemoEntity de3 = new DemoEntity();
        DemoEntity de4 = new DemoEntity();
        DemoEntity de5 = new DemoEntity();
        de1.setName("Mon");
        de1.setNums(120);
        de2.setName("Tue");
        de2.setNums(200);
        de3.setName("Wed");
        de3.setNums(150);
        de4.setName("Thu");
        de4.setNums(170);
        de5.setName("Fri");
        de5.setNums(130);

        productArrayList.add(de1);
        productArrayList.add(de2);
        productArrayList.add(de3);
        productArrayList.add(de4);
        productArrayList.add(de5);

        return productArrayList;
    }*/
}